package com.swt.gap.controller;

import com.swt.gap.model.vo.graph.ExpendMenuVO;
import com.swt.gap.service.GraphService;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 请填写说明
 *
 * @author sx
 * @date 2020/5/27 17:32
 */
@Api(tags = "菜单")
@RestController
@RequestMapping("/menu")
public class MenuController {

    private final GraphService graphService;

    public MenuController(GraphService graphService) {
        this.graphService = graphService;
    }


    @ApiOperation(value = "扩展 二级菜单")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "array", name = "nodeIds", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "taskId", value = "任务id，非必填")
    })
    @ApiResponse(code = 200, message = "ok", response = ExpendMenuVO.class, responseContainer = "List")
    @GetMapping("/expend-menu")
    public ResponseEntity<List<ExpendMenuVO>> getMenuByNodeId(@RequestParam("nodeIds") String[] nodeIds, @RequestParam(value = "taskId")Integer taskId) {
        return ResponseEntity.ok(graphService.listExpendMenu(nodeIds, taskId));
    }
}
